import { BaseWindow } from "../../../../component/window/BaseWindow";
import { LayerManager } from "../../../manager/LayerManager";
import { Language } from "../../../../../extend/language/Language";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { FriendStyle } from "../FriendStyle";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GTextInput } from "../../../../../com/mui/controls/GTextInput";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { GRadioButton } from "../../../../../com/mui/controls/GRadioButton";
import { GCheckBox } from "../../../../../com/mui/controls/GCheckBox";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class PersonalSet
    
    export  class PersonalSet extends BaseWindow
    {
        constructor()
        {
            super();
            this._arySelect = [false, false, false, true, false, false, false, false];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.layer = LayerManager.popupLayer;
            this.titleHeight = 30;
            this.setSize(304, 280);
            title = Language.getString(40338);
            this.create();
            this.addListeners();
            _titleHeight = 27;
            _windowCenter.y = 33;
            return;
        }

        /* internal  */create(): void
        {
            var loc1=ResouceConst.getScaleBitmap("WindowCenterB");
            loc1.x = 21;
            loc1.y = 60;
            loc1.setSize(260, 135);
            this.addChild(loc1);
            this._checkBoxAutoReply = this.createCheckBox(39, Language.getString(40339));
            this._checkBoxRefusedToStranger = this.createCheckBox(195, Language.getString(40340));
            this._checkBoxNotShowOffline = this.createCheckBox(218, Language.getString(40341));
            this._radioEat = this.createRadio(65, Eat);
            this._radioLeveling = this.createRadio(85, Leveling);
            this._radioHook = this.createRadio(105, Hook);
            this._radioNotAt = this.createRadio(125, NotAt);
            this._radioInput = this.createRadio(145);
            this._radioNotAt.selected = true;
            this._inputReply = this.createTextInput();
            this._btnOK = this.createButton(Language.getString(40342), 0);
            this._btnCancel = this.createButton(Language.getString(40343), 1);
            this._checkBoxAutoReply.drawNow();
            this._checkBoxRefusedToStranger.drawNow();
            this._checkBoxNotShowOffline.drawNow();
            this._checkBoxAutoReply.setStyle("textFormat", FriendStyle.textFormat2);
            this._checkBoxRefusedToStranger.setStyle("textFormat", FriendStyle.textFormat2);
            this._checkBoxNotShowOffline.setStyle("textFormat", FriendStyle.textFormat2);
            return;
        }

        /* internal  */addListeners(): void
        {
            this._btnOK.addEventListener(flash.events.MouseEvent.CLICK, this.submitHandler);
            this._btnCancel.addEventListener(flash.events.MouseEvent.CLICK, this.submitHandler);
            return;
        }

        /* internal  */submitHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=false;
            var loc2=null;
            var loc3=false;
            var loc4=false;
            if (arg1.target != this._btnCancel) 
            {
                loc1 = false;
                loc2 = "";
                loc3 = false;
                loc4 = false;
                loc1 = this._checkBoxAutoReply.selected;
                loc3 = this._checkBoxRefusedToStranger.selected;
                loc4 = this._checkBoxNotShowOffline.selected;
                if (this._radioEat.selected) 
                {
                    loc2 = Eat;
                }
                else if (this._radioLeveling.selected) 
                {
                    loc2 = Leveling;
                }
                else if (this._radioHook.selected) 
                {
                    loc2 = Hook;
                }
                else if (this._radioNotAt.selected) 
                {
                    loc2 = NotAt;
                }
                else if (this._radioInput.selected) 
                {
                    loc2 = this._inputReply.text;
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.FriendPersonalSet, {"isAutoReply": loc1, "autoReplyText": loc2, "isRefusedToStranger": loc3, "isNotShowOffline": loc4}));
                this.saveState();
            }
            this.hide();
            return;
        }

        /* internal  */createTextInput(): GTextInput
        {
            var loc1=new GTextInput();
            loc1.x = 42;
            loc1.y = 150;
            loc1.width = 190;
            loc1.height = 40;
            loc1.styleName = "GTextInput";
            loc1.textField.wordWrap = true;
            loc1.textField.maxChars = 40;
            this.addChild(loc1);
            loc1.setStyle("textFormat", FriendStyle.textFormatOffline);
            return loc1;
        }

        /* internal  */createTextField(arg1: string, arg2: Object /* flash.text.TextFormat */, arg3: number, arg4: number, arg5: number, arg6: number): Object /* flash.text.TextField */
        {
            var loc1;
            (loc1 = new Object /* flash.text.TextField */()).text = arg1;
            loc1.defaultTextFormat = arg2;
            loc1.x = arg3;
            loc1.y = arg4;
            loc1.width = arg5;
            loc1.height = arg6;
            loc1.filters = [FilterConst.glowFilter];
            this.addChild(loc1);
            return loc1;
        }

        /* internal  */createRadio(arg1: number, arg2: string=""): GRadioButton
        {
            var loc1=new GRadioButton();
            loc1.y = arg1;
            loc1.x = 24;
            loc1.styleName = "GRadioButton";
            loc1.groupName = "AntoReplyType";
            loc1.label = arg2;
            loc1.width = 250;
            this.addChild(loc1);
            return loc1;
        }

        /* internal  */createCheckBox(arg1: number, arg2: string=""): GCheckBox
        {
            var loc1=new GCheckBox();
            loc1.x = 21;
            loc1.y = arg1;
            loc1.styleName = "GCheckBox";
            loc1.width = 250;
            loc1.label = arg2;
            this.addChild(loc1);
            return loc1;
        }

        /* internal  */createButton(arg1: string, arg2: int=0, arg3: int=47): GButton
        {
            var loc1;
            (loc1 = new GButton()).styleName = "Button";
            loc1.y = 243;
            loc1.x = 176 + 50 * arg2;
            loc1.width = arg3;
            loc1.height = 22;
            loc1.label = arg1;
            this.addChild(loc1);
            return loc1;
        }

        /* internal  */saveState(): void
        {
            this._arySelect[0] = this._radioEat.selected;
            this._arySelect[1] = this._radioLeveling.selected;
            this._arySelect[2] = this._radioHook.selected;
            this._arySelect[3] = this._radioNotAt.selected;
            this._arySelect[4] = this._radioInput.selected;
            this._arySelect[5] = this._checkBoxAutoReply.selected;
            this._arySelect[6] = this._checkBoxRefusedToStranger.selected;
            this._arySelect[7] = this._checkBoxNotShowOffline.selected;
            return;
        }

        /* internal  */resetState(): void
        {
            this._radioEat.selected = this._arySelect[0];
            this._radioLeveling.selected = this._arySelect[1];
            this._radioHook.selected = this._arySelect[2];
            this._radioNotAt.selected = this._arySelect[3];
            this._radioInput.selected = this._arySelect[4];
            this._checkBoxAutoReply.selected = this._arySelect[5];
            this._checkBoxRefusedToStranger.selected = this._arySelect[6];
            this._checkBoxNotShowOffline.selected = this._arySelect[7];
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show();
            this.resetState();
            return;
        }

        /* internal  */static get Eat(): string
        {
            return Language.getString(40334);
        }

        /* internal  */static get Leveling(): string
        {
            return Language.getString(40335);
        }

        /* internal  */static get Hook(): string
        {
            return Language.getString(40336);
        }

        /* internal  */static get NotAt(): string
        {
            return Language.getString(40337);
        }

        /* internal */ /* var */_checkBoxAutoReply: GCheckBox;

        /* internal */ /* var */_checkBoxRefusedToStranger: GCheckBox;

        /* internal */ /* var */_checkBoxNotShowOffline: GCheckBox;

        /* internal */ /* var */_radioEat: GRadioButton;

        /* internal */ /* var */_radioLeveling: GRadioButton;

        /* internal */ /* var */_radioHook: GRadioButton;

        /* internal */ /* var */_radioNotAt: GRadioButton;

        /* internal */ /* var */_radioInput: GRadioButton;

        /* internal */ /* var */_inputReply: GTextInput;

        /* internal */ /* var */_btnOK: GButton;

        /* internal */ /* var */_btnCancel: GButton;

        /* internal */ /* var */_btnApply: GButton;

        /* internal */ /* var */_arySelect: Array<any>;
    }
